


function setMagnetBlock(data) {
    $.ajax({
        url: CXL.ctxPath + '/work/setMagnetBlock',
        type: 'post',
        data: data,
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                //CXL.success("启动成功。");
            } else {
                CXL.error(res.msg);
            }
        },
        fail: function () {
            CXL.error("网络错误！");
        }
    });
}


function setMagnetValue(data) {
    $.ajax({
        url: CXL.ctxPath + '/work/setMagnetValue',
        type: 'post',
        data: data,
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                //CXL.success("启动成功。");
            } else {
                CXL.error(res.msg);
            }
        },
        fail: function () {
            CXL.error("网络错误！");
        }
    });
}

function setStockNumValue(data) {
    $.ajax({
        url: CXL.ctxPath + '/work/setStockNumValue',
        type: 'post',
        data: data,
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                //CXL.success("启动成功。");
            } else {
                CXL.error(res.msg);
            }
        },
        fail: function () {
            CXL.error("网络错误！");
        }
    });
}

function startWork(data) {
    $.ajax({
        url: CXL.ctxPath + '/work/startCraneTask',
        type: 'post',
        data: data,
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                CXL.success("启动成功。");
            } else {
                CXL.error(res.msg);
            }
        },
        fail: function () {
            CXL.error("网络错误！");
        }
    });
}

function stopWork(data) {
    $.ajax({
        url: CXL.ctxPath + '/work/stopCraneTask',
        type: 'post',
        data: data,
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                CXL.success("停止成功。");
            } else {
                CXL.error(res.msg);
            }
        },
        fail: function () {
            CXL.error("网络错误！");
        }
    });
}

function move1(data) {


    layer.confirm('确定要执行移动到辊道动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/move1',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });

}

function suck2(data) {

    layer.confirm('确定要执行吸板动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/suck2',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });


}

function move3(data) {

    layer.confirm('确定要执行移动到垛位动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/move3',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });



}

function place4(data) {

    layer.confirm('确定要执行放板动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/place4',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });



}

function initStockNumValue(craneType){

    $.ajax({
        url: CXL.ctxPath + '/work/initStockNumValue',
        type: 'post',
        data: {craneType:craneType},
        dataType: 'json',
        success: function (res) {
            if (res.success) {
                $('#stockNumberInput').val(res.data.stockPlaceNumber);
                $('#suckSteelNum').val(res.data.suckedSteelNum);
                if(craneType == '11C南' || craneType == '11C北' ){
                    //初始化自动对中标识
                    if(res.data.autoAlignFlag){
                        $("input:radio[name=autoAlign][value=2]")[0].checked = true;
                    } else {
                        $("input:radio[name=autoAlign][value=1]")[0].checked = true;
                    }
                    //初始化对中机构标识
                    if(res.data.alignment1){
                        $("input:checkbox[name=alignment][value=1]").attr("checked","true");
                    }
                    if(res.data.alignment2){
                        $("input:checkbox[name=alignment][value=2]").attr("checked","true");
                    }
                    if(res.data.alignment3){
                        $("input:checkbox[name=alignment][value=3]").attr("checked","true");
                    }
                    if(res.data.alignment4){
                        $("input:checkbox[name=alignment][value=4]").attr("checked","true");
                    }

                    if(res.data.wideSteelFlag){
                       $("input:radio[name=wideSteelInfo][value=true]")[0].checked = true;
                    } else {
                       $("input:radio[name=wideSteelInfo][value=false]")[0].checked = true;
                    }

                }

                if(craneType == "3#横移"){
                    if(res.data.sensorSelectFlag){
                      $("input:radio[name=selectSensor][value=true]")[0].checked = true;
                    } else {
                       $("input:radio[name=selectSensor][value=false]")[0].checked = true;
                    }
                }

            }
        }

    });
}




function move1Plus(data) {


    layer.confirm('确定要执行移动到辊道动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/move1Plus',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });

}

function suck2Plus(data) {

    layer.confirm('确定要执行吸板动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/suck2Plus',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });


}

function move3Plus(data) {

    layer.confirm('确定要执行移动到垛位动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/move3Plus',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });



}

function place4Plus(data) {

    layer.confirm('确定要执行放板动作?', {icon: 3, title:'确认'}, function(index){
        $.ajax({
            url: CXL.ctxPath + '/work/place4Plus',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.success) {
                    CXL.success("启动成功");
                } else {
                    CXL.error(res.msg);
                }
            },
            fail: function () {
                CXL.error("网络错误！");
            }
        });
        layer.close(index);
    });



}